package com.mszlu.blog.controller;

import com.mszlu.blog.service.SysUserService;
import com.mszlu.blog.vo.Result;
import com.mszlu.blog.vo.params.BannedParam;
import com.mszlu.blog.vo.params.LoginParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Package: com.mszlu.blog.controller
 * @ClassName: UsersController
 * @Author: 陈威
 * @CreateTime: 2021/8/30 21:23
 * @Description:
 */
@RestController
@RequestMapping("users")
public class UsersController {

    @Autowired
    private SysUserService sysUserService;

    //等于验证token 通过token从redis中获取用户信息
    @GetMapping("currentUser")
    public Result currentUser(@RequestHeader("Authorization") String token) {
        return sysUserService.fingUserByToken(token);
    }
    //更新密码
    @PostMapping("updatePwd")
    public Result updatePwd(@RequestBody LoginParam param){
        return sysUserService.updatePwd(param);
    }

    //封号
    @PostMapping("bannedAccount")
    public Result bannedAccount(@RequestBody BannedParam bannedParam, @RequestHeader("Authorization") String token){
        return sysUserService.bannedAccount(bannedParam,token);
    }

    @PostMapping("unlockAccount/{uid}")
    public Result unlockAccount(@PathVariable("uid") Long uid){
        return sysUserService.unlockAccount(uid);
    }
}